package com.face.server.main.listener;

import com.face.server.common.utils.log.Logs;
import com.face.server.communication.mina.MinaServer;
import org.slf4j.Logger;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @author yangzhongming
 * @desc 人脸识别出纸机--项目启动时，启动服务监听
 * @date 2022/1/24
 */
@Component
public class ApplicationStartedEventListener implements ApplicationListener<ApplicationStartedEvent> {

    @Resource
    private MinaServer minaServer;

    private final Logger logger = Logs.get();


    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
        logger.info("开始监听Android（人脸识别出纸机）连接");
        // todo 应用启动，获取所有机器修改为离线状态，开启服务，等待机器连接
        minaServer.start();
    }
}
